<?

/********************************************
* match.php
*
* This page will display an embeded player for a given match
* the participants, who won, and a download link.
*
********************************************/

//include files
include "config.php";
include "../lib/db.php";
include "../lib/tbatv_lib.php";

$tba = new tbatvController();

//get passed arguments
$matchid = sanatizeGet($_GET['matchid']);
if ($matchid == "") {
	$matchid = sanatizeGet($_GET['match']);
} 
if ($matchid == "") {
    $matchid = 0;
}
$match = new Match($matchid);
$event = $match->getEvent();

//set up header
$title = $match->getName() . " - " . $event->getName() . " (" . $event->getYear() . ")";

include "header.php";

//Echo the match information
?>
<h1><a href="event.php?eventid=<? echo $event->getEventID() ?>"><? echo $event->getName() ?> (<? echo $event->getYear() ?>)</a></h1>
<h2><? echo $match->getName() ?></h2>
<div class="leftfloat">
	<?	
	include "views/mobile_singlematch.php";
	
	//echo the download link	
	if ($match->hasVideo() == TRUE) {
		$list_of_videos = $match->getVideos();
		foreach ($list_of_videos as $video) {
			?><p><a href="<? echo $video->getPath() ?>" title="<? echo $match->getName() ?> - <? echo $video->getExtension() ?> (<? echo $event->getYear() ?>)"><img src="images/video_icon.png" style="float: left; margin: 8px 5px 0 0; padding: 0 0 16px 0;"> click to download <? echo $video->getExtension() ?> (<? echo $video->getSize() ?> MB).</a></p>
		<? } 
	} else { ?>
		<p>This match has no video online yet.</p>
	<? } ?>
</div>

<?
if ($match->getThanks() != "") {
//echo the thanks
	?>
	<p>Video of this event is provided courtesy of <? echo $match->getThanks(); ?>.</p>
	<?
}
include "footer.php";
?>